package edu.mju.servicebasic.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger2配置类
 *
 */
@Configuration //声明配置类
@EnableSwagger2  //开启swagger2
@Profile({"dev","test"}) //设置运行环境，
public class Swagger2Config {
    /**
     * 配置Swagger2插件
     * 声明swagger网页头信息
     */
    @Bean
    public Docket swaggerApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("Swagger2Api")
                .apiInfo(swaggerInfo())
                .select()
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo swaggerInfo(){
        return new ApiInfoBuilder()
                .title("旅游网站API文档")
                .description("旅游网站API接口定义_cbl")
                .version("1.0.0")
                .contact(new Contact("CBL","https://blog.csdn.net/qq_45770679","cbl225@163.com"))
                .build();
    }
}
